cmake_minimum_required (VERSION 3.16.0)
project (elegrp_thermostat VERSION 1.2.3.4 DESCRIPTION "This is elegrp thermostat project.")

set (CMAKE_SYSTEM_NAME Linux)


set(TOOLCHAIN_PATH "/opt/fsl-imx-x11/4.1.15-2.0.0" CACHE PATH "Path to the toolchain")
set(SDKTARGETSYSROOT ${TOOLCHAIN_PATH}/sysroots/cortexa7hf-neon-poky-linux-gnueabi)
set(CMAKE_PREFIX_PATH ${SDKTARGETSYSROOT})
set(CMAKE_SYSROOT ${SDKTARGETSYSROOT})
set(CROSS_COMPILE ${TOOLCHAIN_PATH}/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-)
set(CC "${CROSS_COMPILE}gcc")
set(CXX "${CROSS_COMPILE}g++")
set(AS "${CROSS_COMPILE}as")
set(AR "${CROSS_COMPILE}ar")
set(NM "${CROSS_COMPILE}nm")
set(GDB "${CROSS_COMPILE}gdb")
set(OBJDUMP "${CROSS_COMPILE}objdump")
set(LD "${CROSS_COMPILE}ld")
set(OBJCOPY "${CROSS_COMPILE}objcopy")
set(RANLIB "${CROSS_COMPILE}ranlib")
set(M4 "m4")
set(ARCH "arm")
set(CMAKE_C_COMPILER ${CROSS_COMPILE}gcc)
set(CMAKE_CXX_COMPILER ${CROSS_COMPILE}g++)
set(CMAKE_C_FLAGS " -O2 -pipe -g -feliminate-unused-debug-types -march=armv7ve -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a7" )
set(CMAKE_CXX_FLAGS " -O2 -pipe -g -feliminate-unused-debug-types -march=armv7ve -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a7")
set(LDFLAGS "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed ")



include(cmake/until.cmake)

if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug)
endif(NOT CMAKE_BUILD_TYPE)

if(CMAKE_BUILD_TYPE MATCHES Release)
  set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
  set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

if(NOT CMAKE_VERBOSE_MAKEFILE)
    message(STATUS "CMAKE_VERBOSE_MAKEFILE: ${CMAKE_VERBOSE_MAKEFILE}")
    set(CMAKE_VERBOSE_MAKEFILE OFF)
endif()
set(CMAKE_CXX_STANDARD 14)
set(PROJ_CMAKE_DIR ${CMAKE_SOURCE_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/target/${CMAKE_BUILD_TYPE}/lib)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/target/${CMAKE_BUILD_TYPE}/bin)

set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)

link_directories(BEFORE ${PROJ_CMAKE_DIR}/share/libs/)
include_directories(BEFORE ${PROJ_CMAKE_DIR}/share/include/)


add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/apps)
# add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libs) 
# add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test)
# add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/share)
